Beginning Python Visualization by Shai Vaingast

Beginning Python Visualization by Shai Vaingast

Author:Shai Vaingast
Language: eng
Format: epub
Publisher: Apress
Published: 2018-09-25T16:00:00+00:00


>>> localtime().tm_year

2014

>>> localtime().tm_yday

144

In this example, I’ve introduced the function localtime(), which returns the current time as a struct_time tuple.

Parsing and Formatting Date and Time

The functions strftime() and strptime() are the two functions you’re most likely to use when dealing with log files. The function strptime(), which was introduced in Chapter 4, accepts a template parse string and the string to parse. It returns a struct_time representation of the time. The function strftime() does the opposite: it transforms a tuple into a string based on a supplied pattern. Both functions use a similar notation to indicate the values in the struct_time tuple, as listed in Table 5-2.

Table 5-2. Selected Identifiers for strftime() and strptime()

Identifier

Description

Values Range



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.